package week11;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author The setting sun
 * @version 1.0
 * @title: WorkServer
 * @description: TODO
 * @date 2021/11/17 10:59
 */
public class WorkServer {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(7777);

        Socket clientSocket = ss.accept();

        DataInputStream dis = new DataInputStream(clientSocket.getInputStream());
        DataOutputStream dos = new DataOutputStream(clientSocket.getOutputStream());
        Scanner s = new Scanner(System.in);
        Boolean isQuit = true;

        while (isQuit) {
            String read = dis.readUTF();
            if (read != null) {
                System.out.println("收到服务端信息：" + read);
            }
            String write = s.next();
            dos.writeUTF(write);


            if (write.equals("拜拜") || read.equals("拜拜")) {
                isQuit = false;
            }
        }
    }
}
